<?php

if (!defined('EXPONENT')) exit('');

/**
 * File Collection Control
 *
 * @author Immanuel192
 * @copyright 2008 - 2009 ABSoft
 * @version 0.1
 *
 * @package Subsystems
 * @subpackage Forms
 */

/**
 * Manually include the class file for formcontrol, for PHP4
 * (This does not adversely affect PHP5)
 */
require_once(BASE."subsystems/forms/controls/formcontrol.php");

/**
 * File Collection Control
 *
 * @package Subsystems
 * @subpackage Forms
 */
class file_collection_control extends formcontrol {
	
	function name() { return "File Collection Control"; }
	function isSimpleControl() { return true; }
	function getFieldDefinition() {
		return array(
			DB_FIELD_TYPE=>DB_DEF_STRING,
			DB_FIELD_LEN=>255);
	}
	
	function file_collection_control($collection_id) {
		$this->collection_id=$collection_id;
	}
	
	function controlToHTML($name) {
	 global $db;
	 $colls=$db->selectDropdown('file_collection','name');
	 $html="<select name='{$name}'><option value=0 ";
	 if ($this->collection_id == 0)
	   $html.="selected";
	$html.=">General</option>";
    foreach ($colls as $value=>$caption) {
			$html .= '<option value="' . $value . '" ';
      if ($value == $this->collection_id) $html .= " selected";
			$html .= '>' . $caption . '</option>';
		}
	 $html.="</select>";	
		return $html;
	}
	
	function form($object) {
		return;
	}
	
	function update($values, $object) {
		return;
	}
}

?>
